package com.qg.lizhanqi.videosquare.adaputer;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.qg.lizhanqi.videosquare.R;
import com.qg.lizhanqi.videosquare.bean.Comments;

import java.util.List;
/**
 * Created by lizhanqi on 2016-8-17-0017.
 */
public class CommentsAdapter extends RecyclerView.Adapter<CommentsAdapter.MyHolder> {
    private static final String TAG = "CommentsAdapter";
    Context context;
    List<Comments.CommlistBean> listCommets;
    LayoutInflater mInflater;
    public CommentsAdapter(Context context, List<Comments.CommlistBean> listCommets) {
        this.context = context;
        this.listCommets = listCommets;
        this.mInflater = LayoutInflater.from(context);
    }
    @Override
    public int getItemCount() {
        return listCommets.size();
    }
    /*创建ViewHolder*/
    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View viewItem = mInflater.inflate(R.layout.comments_items_layout, parent, false);
        MyHolder myHolder = new MyHolder(viewItem);
        return myHolder;
    }
    @Override
    public void onBindViewHolder(final MyHolder holder, final int position) {
        Comments.CommlistBean commlistBean = listCommets.get(position);
        holder.tv_commentText.setText(commlistBean.getCommentconent());
        holder.tv_commentUser.setText(commlistBean.getUsername());
    }
    class MyHolder extends RecyclerView.ViewHolder {
        TextView tv_commentText;
        TextView tv_commentUser;
        public MyHolder(View itemView) {
            super(itemView);
            /*初始化找到控件*/
            tv_commentUser = (TextView) itemView.findViewById(R.id.tv_commentUser);
            tv_commentText = (TextView) itemView.findViewById(R.id.tv_commentText);
        }
    }

}





